<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>单伪元素法</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        .father {
            border: 5px solid #bfa;
        }
        
        .son {
            float: left;
            width: 200px;
            height: 200px;
            background-color: pink;
        }
        
        .father::after {
            content: '';
            display: block;
            clear: both;
            height: 0;
            visibility: hidden;
        }
    </style>
</head>

<body>
    <div class="father">
        <div class="son"></div>
    </div>
</body>

</html>